#一个字符串，找出不重复的最长子串
#输出长度，  起始位置结束位置
# dictr = {}
# string= "aab"
# for c in string:
#     print(c)
#     if c not in dictr:
#         dictr[c] = 1
#         print(dictr)
length= len(string)
max_s=0
loction=[]

for i in range(length):
    for j in range(i,length):
        dictr = {}
        temp=string[i:j+1]
        mark=0
        for c in temp:
            if c not in dictr:
                dictr[c] = 1
            else:
                mark=1
                break
        if mark !=1:
            if j-i+1 > max_s:
                max_s=j-i+1
                loction.append([i,j])
                # print(loction)
m=loction[-1]
print(m)
print(string[m[0]:m[1]+1])
# #
#双指针
# l = 0
# r = 0
# x,y=0,0
# max_s=1
# while r <= length:
#
#     # print(temp)
#     while string[r+1:r+2] not in string[l:r+1]:
#         r+=1
#         print(l,r,"ss")
#         if r-l+1 >max_s:
#             x,y=l,r
#             max_s=r-l+1
#     else:
#         l+=1
#         r+=1
#     if string[l:l+1] == string[r:r+1]:
#         l+=1
#         print(l,r,"1")
#
# print(max_s)
# print(x,y)
# print(string[x:y+1])
class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        if not s:return 0
        left = 0
        lookup = set()
        n = len(s)
        max_len = 0
        cur_len = 0
        for i in range(n):
            cur_len += 1
            while s[i] in lookup:
                lookup.remove(s[left])
                left += 1
                cur_len -= 1
            if cur_len > max_len:max_len = cur_len
            lookup.add(s[i])
        return max_len

